//
//  ConfigModel.m
//  AAPowerApp
//
//  Created by 李恺然 on 2020/2/28.
//  Copyright © 2020 Karl. All rights reserved.
//

#import "ConfigModel.h"

static NSString *kConfigStoredKey = @"kConfigStoredKey";

@implementation ConfigModel

+ (ConfigModel *)cachedConfig{
    NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
    NSDictionary *dic = [ud objectForKey:kConfigStoredKey];
    if (!dic) {
        return nil;
    }
    ConfigModel *model = [ConfigModel yy_modelWithJSON:dic];
    return model;
}

- (BOOL)cacheConfig{
    NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
    NSDictionary *dic = [self yy_modelToJSONObject];
    if (!dic) {
        return NO;
    }
    [ud setObject:dic forKey:kConfigStoredKey];
    return [ud synchronize];
}

@end
